/**      
 * @file		characterCodes.cpp
 * @description		This program takes user input as a character
 *			checks the character to see if it is a lowercase
 *			letter, if it is, the program converts that
 *			letter to an uppercase character and repeats
 *			the process until the user doesn't want to 
 *			convert characters to uppercase.
 * @course		CSCI 123 Section 00000
 * @assignment		Lecture 4 - Sample 10
 * @date		mm/dd/yyyy	
 * @author		Brad Rippe (00000000) brippe@fullcoll.edu
 * @version		3.0
 */
#include <iostream>
#include <cctype>
using namespace std;

/**
 * Prompt the user for a lowercase character
 * @pre   none
 * @post  user has been prompted to type a lowercase character
 */
void promptForLowerChar();

/**
 * Outputs a invalid character message
 * @pre   user has input a character and it has been tested for 
 *        validity
 * @post  message as been sent to the screen notifying the user
 *        that an invalid character has been input
 */
void invalidCharMsg();

/**
 * Outputs the initial character typed in by the user
 * then converts the lowercase character to an uppercase
 * character and outputs the result
 * @param charInput the lowercase character to be converted
 * @pre   charInput is a lowercase character
 * @post  the lowercase character has been output as an uppercase
 *        character
 */
void outputUpperCase(char charInput);

/**
 * Prompts the users to input a 
 * then converts the lowercase character to an uppercase
 * character and outputs the result
 * @pre   none
 * @post  the lowercase character has been output as an uppercase
 *        character
 */
void promptToContinue();

/**
 * @return zero if the application executes successfully
 */
int main() {
	char theChar = '1';
	while(theChar != '0') {
		promptForLowerChar();
		cin >> theChar;
		// islower returns 1 if the character is a lowercase
		// letter and 0 if it is not
		if(!islower(theChar)) {
			invalidCharMsg();
			continue;
		}
		outputUpperCase(theChar);
		promptToContinue();

		cin >> theChar;
	}
	return 0;
}

void promptForLowerChar() {
	cout << "Please type a lowercase character ";
	cout << "and I will make it uppercase.\n";
}

void invalidCharMsg() {
	cout << "You've typed an invalid character!\n";
	cout << "Please try again\n";
}

void outputUpperCase(char charInput) {
	cout << "You typed the character '"
		<< charInput
		<< "'\n";
	cout << "I can capitalize the char '"
		<< static_cast<char>(toupper(charInput))
		<< "'\n";
}

void promptToContinue() {
	cout << "Would you like to continue?\n";
	cout << "Type '1' for yes and '0' for no\n";
}
